import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { ProductComponent } from './product/product.component';
import { Code404Component } from './code404/code404.component';
import { ProductDetailComponent } from './product-detail/product-detail.component';
import { ShopComponent } from './shop/shop.component';
import { ChatComponent } from './chat/chat.component';
import { LoginGuard } from './guard/login.guard';
import { UnsavedGuard } from './guard/unsaved.guard';
import { ProductResolve } from './guard/resolve.guard';

const routes: Routes = [{ path: "", redirectTo: '/home', pathMatch: "full" },
  { path: "home", component: HomeComponent, canActivate: [LoginGuard], canDeactivate: [UnsavedGuard] },
  { path: "chat", component: ChatComponent, outlet:"aux" },
{
  path: "product", component: ProductComponent,
  children: [
    { path: "", component: ProductDetailComponent },
    { path: "shop", component: ShopComponent }],
  resolve: { prod: ProductResolve}
},
{ path: "**", component: Code404Component }];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
  providers: [LoginGuard, UnsavedGuard, ProductResolve]
})
export class AppRoutingModule { }
